package com.cxg.fairy.ec.detail;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatTextView;
import android.support.v7.widget.LinearLayoutCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

import com.cxg.fairy.ui.recycler.MultipleItemEntity;
import com.diabin.latte.ec.R;

import java.util.List;

/**
 * Created by gabrielsung on 2018/4/6 0006.
 */

public class StandardAdapter extends ArrayAdapter {


    public StandardAdapter(@NonNull Context context, int resource, @NonNull List data) {
        super(context, resource, resource, data);
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        MultipleItemEntity entity = (MultipleItemEntity) getItem(position);
        LinearLayoutCompat view = (LinearLayoutCompat) LayoutInflater.from(parent.getRootView().getContext()).inflate(R.layout.item_goods_detail_standard, parent,false);
        AppCompatTextView tvName = (AppCompatTextView) view.findViewById(R.id.standard_name);
        AppCompatTextView tvValue = (AppCompatTextView) view.findViewById(R.id.standard_value);
        tvName.setText((String) entity.getField("name"));
        tvValue.setText((String)entity.getField("value"));
        return view;
    }
}
